public class PrintChar implements Runnable{


    private char c;
    private int times;

    public PrintChar() {
    }

    public PrintChar(char c, int times) {
        this.c = c;
        this.times = times;
    }

    @Override
    public void run() {
//        try {  //不能只try catch Thread，否则就算异常了，线程也不会结束
        int i = 0;
            for(i = 0 ; i<times ; i++) {
//                if(Thread.currentThread().isInterrupted()) { //检查线程标志位有没有人让我停止
//                    System.out.println("打印完了");
//                    break;//如果需要打断，则停止
//                }
                if(Thread.interrupted()) { //检查是否有人想终止线程，如果有，重置状态，继续运行
                    System.out.println(Thread.currentThread().isInterrupted());
                }
                System.out.println(c);
//                if (i >= 50) {
//                    Thread.sleep(1000);
//                }
            }
        System.out.println(i+"打印完了");
//        System.out.println(i);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
    }
}
